<template>
  <view class="nav-container">
    <view 
      v-for="(item, index) in navItems" 
      :key="index"
      class="nav-item" 
      :class="{ active: activeTab === item.value }"
      @click="handleItemClick(item.value)"
    >
      <text class="nav-text">{{ item.label }}</text>
      <view class="nav-indicator"></view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'AdvancedNavBar',
  props: {
    navItems: {
      type: Array,
      default: () => [
        { label: 'ئەزالىق سىتىۋىلىش', value: 'vip' },
        { label: 'چەك تارتىش', value: 'lottery' }
      ]
    },
    modelValue: {
      type: String,
      default: 'vip'
    }
  },
  data() {
    return {
      activeTab: this.modelValue
    }
  },
  watch: {
    modelValue(newVal) {
      this.activeTab = newVal
    }
  },
  methods: {
    handleItemClick(tab) {
      this.activeTab = tab
      // 发出 update:modelValue 事件，这是 Vue 3 v-model 所需的
      this.$emit('update:modelValue', tab)
      this.$emit('change', tab)
      console.log('导航栏点击:', tab, '发出 update:modelValue 事件')
    }
  }
}
</script>

<style scoped>
.nav-container {
  display: flex;
  background: rgba(29, 29, 29, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.6),
    inset 0 1px 1px rgba(255, 255, 255, 0.05);
  padding: 5rpx 24px;
  border-radius:0 0 20rpx 20rpx;
  overflow: hidden;
  position: relative;
  margin-top: 20rpx;
}

.nav-item {
  flex: 1;
  text-align: center;
  padding: 22px 0;
  position: relative;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 3px solid transparent;
  border-radius: 12px;
  margin: 6px;
  background: transparent;
  overflow: hidden;
}

.nav-item.active {
  border-bottom-color: #ff0000;
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.15), rgba(255, 0, 0, 0.05));
  box-shadow: 
    inset 0 2px 8px rgba(255, 0, 0, 0.3),
    0 4px 16px rgba(255, 0, 0, 0.2);
  transform: translateY(-2px);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.nav-item:active {
  transform: scale(0.95) translateY(0);
  background: rgba(255, 0, 0, 0.1);
}

.nav-text {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  position: relative;
  z-index: 2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

.nav-item.active .nav-text {
  color: #ff0000;
  text-shadow: 0 0 8px rgba(255, 0, 0, 0.6);
}

.nav-indicator {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #ff0000, transparent);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px;
}

.nav-item.active .nav-indicator {
  width: 70%;
  box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);
}
</style>